home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
ms_dos
/
txf
/
src
/
txflog2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-08
|
10KB
|
439 lines
/***************
*
* g:\exe\txf\src\txflog2.c
*/
#include "txf.h"
#define BYTE(x) *((unsigned char *)(x))
#define BIT_CHK(x,f) ((int)(BYTE(x+(f/8)) >> 7-f%8) & 1)
void get_forum(int type)
{
char *dmyptr;
log_pname[0] = NUL;
if (type == 1) {
dmyptr = log_bufptr - 49;
while (*dmyptr > ' ') {
dmyptr--;
}
}
if (type == 2) {
dmyptr = log_bufptr + 1;
}
sscanf(dmyptr, "%16s", log_fname);
}
void get_libno(int type)
{
char *dmyptr;
if ((type == 1) || (type == 2)) {
dmyptr = log_bufptr + 1;
}
sscanf(dmyptr, "%[0-9]", log_libstr);
}
void get_titlestr()
{
char *tmp;
tmp = log_bufptr;
/* 暫定 */
while ( matchstr("re:", tmp)) {
tmp += 3;
}
while ( matchstr("re'*%:", tmp)) {
tmp += 5;
}
if (strncmp(tmp, log_resstr, strlen(log_resstr)))
strcpy(log_titlestr, log_resstr);
strncat(log_titlestr, tmp, 41);
tmp = strchr(log_titlestr, 0x0d);
if (tmp != NULL) {
*tmp = NUL;
}
else {
if (strlen(log_titlestr) > 40) {
*(jstradv(log_titlestr, btom(log_titlestr, 38))) = NUL;
}
}
if (viewmode > 9) {
fprintf(stderr, "Info:TITLE:%s\n", log_titlestr);
}
}
void meschk(int style)
{
if (style == 3) {
sscanf(log_bufptr, "%[0-9]", log_reply);
log_bufptr += 10;
strncpy(log_resp, log_bufptr, 8);
log_bufptr += 28;
get_titlestr();
if ((log_bufptr = strchr(log_bufptr, 0x0a)) == NULL) {
printf("Error:find EOF before title+1 line");
exit(1);
}
log_bufptr += 2;
sscanf(log_bufptr, "%2d", &log_mesno);
}
else if (style == 2) {
log_bufptr += 2;
sscanf(log_bufptr, "%s MES(%d)", log_fname, &log_mesno);
if (log_mesno == 0) {
sscanf(log_bufptr, "MES(%d)", &log_mesno);
}
*log_reply = NUL;
*log_titlestr = NUL;
}
else if (style == 1) {
sscanf(log_bufptr, "%2d", &log_mesno);
*log_reply = NUL;
*log_titlestr = NUL;
}
else if (style == 8) {
sscanf(log_bufptr, "%[0-9]", log_reply);
log_bufptr += 12;
strncpy(log_resp, log_bufptr, 8);
log_bufptr += 27;
get_titlestr();
if ((log_bufptr = strchr(log_bufptr, 0x0a)) == NULL) {
printf("Error:find EOF before title+1 line");
exit(1);
}
log_bufptr += 2;
sscanf(log_bufptr, "%2d", &log_mesno);
}
if (log_pname[0] == NULL) {
printf("forum=%s;mes=%d;reply=%s;resp=%s;title=%s\n"
, log_fname, log_mesno, log_reply, log_resp, log_titlestr);
}
else {
printf("patio=%s;mes=%d;reply=%s;resp=%s;title=%s\n"
, log_pname, log_mesno, log_reply, log_resp, log_titlestr);
}
}
void dlibchk(int style)
{
int i=0, j=0, type=CT_ANK, dmy=0;
if (style == 5) { /* for 週間FTOWNS */
log_bufptr += 3;
sscanf(log_bufptr, "%4d", &log_downno);
log_bufptr += 4;
}
else if (style == 4) {
sscanf(log_bufptr, "%4d", &log_downno);
log_bufptr += 39;
}
for (i=0;((j<12)&&(*(log_bufptr+i)!='.')&&(*(log_bufptr+i)!='\n'));i++) {
if (BIT_CHK(filechr, *(log_bufptr + i)) ||
((type = chkctype(*(log_bufptr + i), type)) != CT_ANK)) {
*(log_downname + j) = *(log_bufptr + i);
j++;
}
}
if (*(log_bufptr+i) == '.') {
*(log_downname+j) = '.';
j++;
log_bufptr += i;
for (i = 1; (*(log_bufptr + i) != '.') &&
(*(log_bufptr+i)!='\n'); i++) {
if (i == 1) {
while (*(log_bufptr + i) == ' ') {
dmy++;
i++;
}
}
if (BIT_CHK(filechr, *(log_bufptr+i)) ||
((type = chkctype((*log_bufptr + i), type)) != CT_ANK)) {
*(log_downname + j) = *(log_bufptr + i);
j++;
}
if ((i - dmy) >= 3) {
break;
}
}
}
strcpy(log_docfile, log_downname);
if (strchr(log_docfile, '.')) {
strcpy(strchr(log_docfile, '.'), ".GGG");
}
else {
#if !LIBNAME
if (strlen(log_downname) <= 8) {
strcat(log_downname, ".DAT");
strcat(log_docfile, ".GGG");
}
else {
if (nthctype(log_downname, 7) != CT_KJ1) {
strcpy(log_downname + 8, ".DAT");
strcpy(log_docfile + 8, ".GGG");
}
else {
strcpy(log_downname + 7, ".DAT");
strcpy(log_docfile + 7, ".GGG");
}
}
#else
if (sprintf(log_downname, "LIB%d_%d.LZH",
atoi(log_libstr), log_downno) > 12) {
sprintf(log_downname, "%d_%d.LZH",atoi(log_libstr), log_downno);
sprintf(log_docfile, "%d_%d.GGG",atoi(log_libstr), log_downno);
}
else {
sprintf(log_docfile, "LIB%d_%d.GGG",atoi(log_libstr), log_downno);
}
#endif
}
printf("forum=%s;libno=%s;datano=%d;docfile=%s;datafile=%s;\n"
,log_fname, log_libstr, log_downno, log_docfile, log_downname);
}
void ffmtopchk()
{
/*
12/12[TOWNS] ぼむぼむ (DL 5-433)
*/
int i, lib, len, cline = 0;
char *tmpptr, target[80], str[4]="(DL";
tmpptr = str;
for (i = 0; i < 80; i++) {
if (*log_bufptr != *tmpptr) {
tmpptr = str;
log_bufptr++;
if (*log_bufptr == 0x0a) {
break;
}
}
else {
tmpptr++;
log_bufptr++;
if (*tmpptr == NUL) break;
}
}
if (*tmpptr == NUL) {
sscanf(log_bufptr + 1, "%2d-%4d", &lib, &log_downno);
len = sprintf(target, "LIB%d_%d.lzh", lib, log_downno);
strcpy(log_downname, (target + (len > 12 ? 3 : 0)));
strcpy(log_docfile, log_downname);
strcpy(strchr(log_docfile, '.'), ".GGG");
}
else {
printf("Error:Fatal System Error,cannot continue.\n");
exit(1);
}
for (pfstr[0] = sfstr[0]; *pfstr[0] != NUL; log_bufptr++) {
if ((*pfstr[0] == *log_bufptr) || (*pfstr[0] == '*')) {
pfstr[0]++;
}
else {
pfstr[0] = sfstr[0];
}
if (*log_bufptr == 0x0a) {
cline++;
if (cline > 100) break;
}
}
if (*pfstr[0]==NUL) get_forum(1);
printf("forum=%s;libno=%d;datano=%d;docfile=%s;datafile=%s;\n"
,log_fname, lib, log_downno, log_docfile, log_downname);
}
void hpchk()
{
int i, type = CT_ANK;
char *handle, *tmp;
char tmptitle[64];
if ((handle = getenv("TXFUSER")) != NULL) {
strncpy(log_handle, handle, 16);
}
#if 0
else if ((handle = getenv("USER") != NULL) {
strncpy(log_handle, handle, 16);
}
#endif
log_bufptr += 23;
strncpy(log_resp, log_bufptr, 8);
log_bufptr += 14;
if (log_hpstyle == 1) {
tmp = log_bufptr;
if (((tmp = jstrchr(tmp, ':')) != NULL) && (tmp < strchr(log_bufptr, 0x0d))) {
log_bufptr = tmp + 1;
}
}
get_titlestr();
if (*log_handle != NUL) {
if (log_hpstyle == 1) {
if (sprintf(tmptitle, "%s:%s", log_handle, log_titlestr) > 64) {
printf("Error:Fatal System Error,cannot continue.\n");
exit(1);
}
strncpy(log_titlestr, tmptitle, 42);
}
else {
if (jstrchr(log_titlestr, '<') != NULL)
*(jstrchr(log_titlestr, '<') + 2) = NUL;
else strcat(log_titlestr, "<");
strncat(log_titlestr, log_handle, 40 - strlen(log_titlestr));
}
}
for (i = 0; i <= 40; i++) {
if (*(log_titlestr + i) == NUL) {
break;
}
type = chkctype(*(log_titlestr + i), type);
}
if (type != CT_KJ2) {
if (i > 40) i = 40;
*(log_titlestr + i) = NUL;
}
else {
*(log_titlestr + 39) = NUL;
}
printf("hp=%s;resp=%s;title=%s\n", log_idstr, log_resp, log_titlestr);
}
void mailchk()
{
/*
2 山田 弘明 PEE01244 05/17 10:21
題名:FAPX406B.LZH
*/
log_bufptr += 22;
strncpy(log_idstr, log_bufptr, 8);
if ((log_bufptr = strchr(log_bufptr, 0x0a)) == NULL) {
printf("Error:find EOF before title+1 line");
exit(1);
}
log_bufptr += 11;
get_titlestr();
printf("mail=%s;title=%s\n", log_idstr, log_titlestr);
}
int matchstr(char *form, char *txtptr)
{
char *logtmp, *strtmp;
int i, trueflg = 0, count = 0;
logtmp = txtptr;
strtmp = form;
while ((*strtmp != NUL) && (*logtmp != 0x0a)) {
trueflg = FALSE;
switch (*strtmp) {
case '%':
if (isdigit(*logtmp) || (*logtmp == ' ')) {
trueflg = TRUE;
}
break;
case '*':
if (isalpha(*logtmp)) {
trueflg = TRUE;
}
break;
case '_':
if (*logtmp == ' ') {
trueflg = TRUE;
}
break;
case '$':
trueflg = TRUE;
break;
case 0x27:
strtmp++;
if (*logtmp == *strtmp) {
trueflg = TRUE;
}
break;
case '^':
strtmp++;
count = ((*strtmp) - ('0'));
strtmp++;
while (trueflg != TRUE) {
for (i = 0; i < count; i++) {
if (*(logtmp + i) != *(strtmp + i)) {
break;
}
}
if (i != count) {
logtmp++;
if (*logtmp == 0x0a) {
break;
}
}
else {
trueflg = TRUE;
}
}
break;
default:
if (islower(*strtmp)) {
if (tolower(*logtmp) == *strtmp) {
trueflg = TRUE;
}
}
else {
if (*logtmp == *strtmp) {
trueflg = TRUE;
}
}
}
if (trueflg != TRUE) {
return (FALSE);
}
strtmp++;
logtmp++;
}
return (TRUE);
}
int linestyle()
{
/*
char logstr_mes1[30]="%% %%%%% ( %%%) %%/%% ";
char logstr_mes2[15]="- ^1 MES(%%):";
char logstr_mes3[41]="%%%/%%% ***%%%%% $$$$$$$$$$$$$$$$ ";
char logstr_mes4[42]="%%%%%/%%%%% ***%%%%% $$$$$$$$$$$$$$$$ ";
char logstr_dlib[42]="%%%%$ ***%%%%% %%/%%/%% %%%%%%% %%%% * ";
char logstr_wftowns[5]=" #%";
char logstr_hp[40]="%%% [%%/%%/%% %%:%%] ***%%%%% ";
char logstr_mail[44]="%% $$$$$$$$$$$$$$$$$ ***%%%%% %%/%% %%:%%";
char logstr_ffmtop[22]="%%/%%[^1]^3(DL%%-%%%)";
*/
if (matchstr(logstr_mes1, log_bufptr)) return (1);
if (matchstr(logstr_mes2, log_bufptr)) return (2);
if (matchstr(logstr_mes3, log_bufptr)) return (3);
if (matchstr(logstr_dlib, log_bufptr)) return (4);
if (matchstr(logstr_wftowns, log_bufptr)) return (5);
if (matchstr(logstr_hp, log_bufptr)) return (6);
if (matchstr(logstr_mail, log_bufptr)) return (7);
if (matchstr(logstr_mes4, log_bufptr)) return (8);
if (matchstr(logstr_ffmtop, log_bufptr)) return (9);
return (0);
}